package com.dm.cloud.core.mode;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultModel<T extends Object> {

    private Integer status;

    private String msg;

    private T data;

    public ResultModel(String msg){
        this.msg=msg;
        this.status=200;
    }
    public ResultModel(T data){
        this.data=data;
        this.status=200;
    }
    public static ResultModel success() {
        return new ResultModel(200,"success",null);
    }

    public static ResultModel success(String msg) {
        return new ResultModel(200,msg,null);
    }
    public static ResultModel successData(String data) {
        return new ResultModel(200,"success",data);
    }
    public static ResultModel success(Object data) {
        return new ResultModel(200,"success",data);
    }

    public static ResultModel success(String msg,Object data) {
        return new ResultModel(200,msg,data);
    }
    public static ResultModel success(Integer code,Object data) {
        return new ResultModel(code,"success",data);
    }

    public static ResultModel serverErr(String msg) {
        return err(500,msg);
    }

    public static ResultModel err(int status,String msg) {
        return new ResultModel(status,msg,null);
    }
}
